package lxq.away3d;

import away3d.bounds.NullBounds;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.debug.WireframeAxesGrid;
import away3d.entities.Entity;
import away3d.entities.Mesh;
import away3d.materials.MaterialBase;
import away3d.primitives.LineSegment;
import away3d.primitives.WireframeCube;

import flash.display.Stage;
import flash.geom.Vector3D;

import lxq.away3d.controller.OrbitController;
import lxq.away3d.primitives.Ball;
import lxq.away3d.primitives.Box;
import lxq.away3d.primitives.Cone;
import lxq.away3d.primitives.Line;

class MeshFactory
{
private static var orbit:OrbitController;
public function new()
{
}
public static function createBox(scene:Scene3D=null,width:Float=50,height:Float=50,depth:Float=50,ws:UInt=1,hs:UInt=1,ds:UInt=1,material:MaterialBase=null):Box{
	var box:Box=new Box(width,height,depth,ws,hs,ds,material);
	if(scene)scene.addChild(box);
	return box;
}
public static function createBall(scene:Scene3D=null,radius:Float=50,ws:UInt=16,hs:UInt=16,material:MaterialBase=null):Ball{
	var ball:Ball=new Ball(radius,ws,hs,material);
	if(scene)scene.addChild(ball);
	return ball;
}
public static function createCone(scene:Scene3D=null,radius:Float=50,height:Float=100,ws:UInt=16,hs:UInt=16,closed:Bool=true,material:MaterialBase=null):Cone{
	var cone:Cone=new Cone(radius,height,ws,hs,closed,material);
	if(scene)scene.addChild(cone);
	return cone;
}
public static function createAxisXYZ(scene:Scene3D,length:Float=1000):Void{
	var container:ObjectContainer3D=new ObjectContainer3D();
	var linex:Line=new Line(new Vector3D(),new Vector3D(length,0,0),0xff0000);
	var liney:Line=new Line(new Vector3D(),new Vector3D(0,length,0),0x00ff00);
	var linez:Line=new Line(new Vector3D(),new Vector3D(0,0,length),0x0000ff);
	container.addChild(linex);
	container.addChild(liney);
	container.addChild(linez);
	if(scene)scene.addChild(container);
}
public static function createOrbitController(stage:Stage,lookAt:ObjectContainer3D=null,camera:Entity=null,max:Float=1000,min:Float=100):Void{
	orbit=new OrbitController(stage,lookAt,camera,max,min)
}
public static function updateController():Void{
	if (orbit) {
	orbit.loop();
	trace(orbit.tiltAngle);
	}
}
}